<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>PHP 5 Operators</title>
</head>
<body>
<h1>PHP 5 Operators</h1>

<div>
    <h3>PHP Arithmetic Operators</h3>
    <?php
    $x = 10;
    $y = 6;
    echo($x + $y); // outputs 16
    echo("<br>");
    echo($x - $y); // outputs 4
    echo("<br>");
    echo($x * $y); // outputs 60
    echo("<br>");
    echo($x / $y); // outputs 1.6666666666667
    echo("<br>");
    echo($x % $y); // outputs 4
    ?>
</div>
<div>
    <h3>PHP Assignment Operators</h3>
    <?php
    $x = 10;
    echo $x; // outputs 10

    $y = 20;
    $y += 100;
    echo $y; // outputs 120

    $z = 50;
    $z -= 25;
    echo $z; // outputs 25

    $i = 5;
    $i *= 6;
    echo $i; // outputs 30

    $j = 10;
    $j /= 5;
    echo $j; // outputs 2

    $k = 15;
    $k %= 4;
    echo $k; // outputs 3
    ?>
</div>
<div>
    <h3>PHP String Operators</h3>
    <?php
    $a = "Hello";
    $b = $a . " world!";
    echo($b); // outputs Hello world!

    echo("<br>");

    $x = "Hello";
    $x .= " world!";
    echo($x); // outputs Hello world!
    ?>
</div>
<div>
    <h3>PHP Increment/Decrement Operators</h3>
    <?php
    $x = 10;
    echo ++$x; // outputs 11

    $y = 10;
    echo $y++; // outputs 10

    $z = 5;
    echo --$z; // outputs 4

    $i = 5;
    echo $i--; // outputs 5
    ?>
</div>
<div>
    <h3>PHP Comparison Operators</h3>
    <?php
    $x = 100;
    $y = "100";

    var_dump($x == $y);
    echo "<br>";
    var_dump($x === $y);
    echo "<br>";
    var_dump($x != $y);
    echo "<br>";
    var_dump($x !== $y);
    echo "<br>";

    $a = 50;
    $b = 90;

    var_dump($a > $b);
    echo "<br>";
    var_dump($a < $b);
    ?>
</div>
<div>
    <h3>PHP Array Operators</h3>
    <?php
    $x = array("a" => "red", "b" => "green");
    $y = array("c" => "blue", "d" => "yellow");
    $z = $x + $y; // union of $x and $y
    var_dump($z);
    var_dump($x == $y);
    var_dump($x === $y);
    var_dump($x != $y);
    var_dump($x <> $y);
    var_dump($x !== $y);
    ?>
</div>
</body>
</html>